// mixins.js
import toolBase from "../common/utils/tool.js"
import {
	LoginCenterApi
} from '../api/serves';
import store from '../store';
import {
	ref,
	computed,
	onMounted
} from "vue";

export const useCounter = () => {
	const tool = toolBase.tool;
	const getUserInfo = async () => {
		const {
			code,
			data,
			msg
		} = await LoginCenterApi.get_user_detail()
		if (code != 1) return tool.alert(msg)
		store.commit('setUserInfo', data)
		tool.storage("userInfo", data)
	};
	const userInfo = computed(() => {
		return store.state.userInfo
	})
	return {
		getUserInfo,
		userInfo,
		tool
	};
};